import { fromJS } from 'immutable'
import * as actionTypes from './actionTypes'

const defaultState = fromJS({
	title: '衡水中学，被外地人占领的高考工厂',
	content: '<img alt="" src="http://upload-images.jianshu.io/upload_images/3301720-db890fabf626e0ac.jpg?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp" /><p><b>说起来很惭愧</b>，在简书写了一年的文，至今，我还是原来的我，既没有签约，也没有写出爆文，甚至连一篇像样点的、拿得出手的文字也没有。</p>'
})

const changeDetail = (state, action) => {
	return state.merge({
		title: fromJS(action.title),
		content: fromJS(action.content)
	})
}

export default (state = defaultState, action) => {
	switch (action.type) {
		case actionTypes.CHANGE_DETAIL:
			return changeDetail(state, action)
		default:
			return state
	}
}